package logic

import (
	"context"
	"srv/model/mysql"

	"srv/internal/svc"
	"srv/srv"

	"github.com/zeromicro/go-zero/core/logx"
)

type OrderListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewOrderListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OrderListLogic {
	return &OrderListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *OrderListLogic) OrderList(in *srv.OrderListRequest) (*srv.OrderListResponse, error) {
	// todo: add your logic here and delete this line

	var order []mysql.Order
	mysql.DB.Find(&order)
	var lists []*srv.OrderList
	for _, m := range order {
		list := srv.OrderList{
			OrderNum:  m.OrderNum,
			UserId:    int64(m.UserId),
			GoodName:  "ttgg三巡原价v",
			GoodPrice: 466,
			Num:       1,
			PayTime:   m.PayTime,
			PayType:   int64(m.PayType),
		}
		lists = append(lists, &list)
	}
	return &srv.OrderListResponse{
		List: lists,
	}, nil
}
